﻿using Ivory;
using Ivory.GUI;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Schism;
using Schism.IO;
using Schism.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Defender
{
    public class MainMenu : MainMenuScreen
    {
        //Fields
        private TextButton GenerateButton;
        private TextButton MapTest01;


        //ctor
        public MainMenu(Game game)
            : base(game)
        {

        }

        //Methdos
        public override void RenderMenu(SpriteBatch batch, GameTime time)
        {
            batch.Begin();
            GenerateButton.DrawComponent(batch, time);
            MapTest01.DrawComponent(batch, time);

            batch.End();
        }
        public override void UpdateMenu(GameTime time, InputControl input)
        {
            GenerateButton.UpdateComponent(input, time);
            MapTest01.UpdateComponent(input, time);
        }

        public override bool LoadAssets()
        {
            GenerateButton = new TextButton(Game, FontBank.GetFnt("Arial16"), "Generate Map", new Vector2(0, 100));
            GenerateButton.LeftClicked += (s, e) =>
                {
                    WorldIO io = new WorldIO();
                    io.WorldCellMap = CellMapBuilder.Basic;
                    io.Save("dungeon_mapTest.dung");
                };

            MapTest01 = new TextButton(Game, FontBank.GetFnt("Arial16"), "Map Test 01", new Vector2(0, 150));
            MapTest01.LeftClicked += (s, e) =>
            {
                Manager.SwitchToGameScreen(LevelMappingTest.Key);
            };

            return true;
        }
    }
}
